/**
 *	主要功能：
 *      1.创建系统视图
 *  作者：liuzhh
 */
 
 /**用户资源视图**/
create or replace view v_secu_user_resource as
(
      select rownum as id,f.user_id,f.creator,f.begin,f.end,
           f.resource_type,f.name,f.key,f.value,f.disport
      from
      (
          select
                distinct a.user_id,a.creator,a.begin,a.end,
                c.resource_type,c.name,c.key,c.value,c.disport
          from
                t_secu_user a,
                t_secu_role b,
                t_secu_resource c,
                t_secu_role_rela_user d,
                t_secu_role_rela_resource e
          where
                a.id=d.secu_user(+)
                and
                d.secu_role=e.secu_role(+)
                and
                d.secu_role=b.id(+)
                and
                e.secu_resource=c.id(+)
                and
                c.id is not null
      ) f
);

 /**查询结果视图**/
create or replace view v_search as
  select 
    rownum id,
    a.MODULEID,
    a.TITLE,
    a.CREATOR,
    a.BEGIN,
    a.END,
    a.MODULE 
  from 
  (
  select  
    id
    moduleid,
    title,
    creator,
    begin,
    end,
    1 module 
  from t_busi_share_reference 
  union all 
  select   
    id
    moduleid,
    title,
    creator,
    begin,
    end,
    2 module 
  from t_busi_product_reference
  ) a;
